/*
 * @Author: xiangru.xiao xiangru.xiao@mthreads.com
 * @Date: 2023-05-10 16:38:07
 * @LastEditors: xiangru.xiao xiangru.xiao@mthreads.com
 * @LastEditTime: 2023-05-17 14:13:02
 * Copyright (c) 2023 by Moore Threads, All Rights Reserved. 
 */
#include <string>
#include "objectfactory.h"
#include "node.h"
#include "cu_helper.h"
#include "kernel.cuh"

class MaxSp_compute : public Node
{
public:
    MaxSp_compute()
    {
        nodeUint = "GFLOPS";
    }
    std::string name() override
    {
        return "maxsp-compute";
    }
    std::string describe() override
    {
        return "单精度浮点数性能";
    }
    Node::NodeType  nodeType() override
    {
        return NodeTP_DataSpeed;
    }
protected:
    bool startup() override;
    bool perform() override;
    void shutdown() override;
private:
    int        deviceid;
};

bool MaxSp_compute::startup()
{

    deviceid = deviceinfo->deviceID();
    CHECK_CUDA_ERROR(cudaSetDevice(deviceid));
    return true;
}

bool MaxSp_compute::perform()
{
    nodeValue = runComputeKernel<float, ma_op>(deviceinfo);
    return true;
}

void MaxSp_compute::shutdown()
{

}
REGISTER_OBJECT(Node, MaxSp_compute)
